xref: /haiku/docs/apps/mail/Mass Mailing Tips/MailToTemplate (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1#!/bin/sh
2
3# Make a mail merge letter by combining data from a given people file and a
4# template letter text file.
5# $Revision: 1.1 $
6# Some code from Scot Hacker's PeoplePorter http://www.bebits.com/app/1747
7
8PeopleFile=$1
9echo "Mail merging using people file: $PeopleFile"
10
11Name=$(catattr META:name "$PeopleFile" | sed s/\ \:\ /%/g | cut -f3 -d\%)
12EMail=$(catattr META:email "$PeopleFile" | sed s/\ \:\ /%/g | cut -f3 -d\%)
13Company=$(catattr META:company "$PeopleFile" | sed s/\ \:\ /%/g | cut -f3 -d\%)
14
15sed "s/NAME/$Name/g" <TemplateLetter.txt >/tmp/stage1
16sed "s/EMAIL/$EMail/g" </tmp/stage1 >/tmp/stage2
17sed "s/COMPANY/$Company/g" </tmp/stage2 >/tmp/stage3
18mail -v -s "Test Message to $Name" "$EMail" </tmp/stage3
19